package GUI;
import javax.swing.*;
import javax.swing.border.LineBorder;

import java.awt.*;
import java.awt.image.BufferedImage;
@SuppressWarnings("serial")
public class CandidatePanel extends JPanel
{
	public CandidatePanel(String name,String program,ImageIcon picture)
	{
		setSize(650, 300);
		setBorder(new LineBorder(Color.DARK_GRAY,7));
		setLayout(null);
		setBackground(Color.white);
		
		JLabel candidateName = new JLabel(name);
		candidateName.setFont(new Font(Font.SANS_SERIF,Font.BOLD, 30));
		candidateName.setBounds(170,0,470,50);
		
		ImageIcon icon = new ImageIcon("images.jpg");
		JLabel img = new JLabel(scale(icon.getImage(), 1));
		img.setBorder(new LineBorder(Color.DARK_GRAY,3));
		img.setBounds(10,10,150,190);
		
		JTextPane programText = new JTextPane();
		programText.setText(program);
		programText.setEditable(false);
		programText.setFont(new Font(Font.SERIF,Font.ITALIC,16));
		
		JScrollPane editorScrollPane = new JScrollPane(programText);
		editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		editorScrollPane.setBounds(170, 50, 470, 230);
		editorScrollPane.setBorder(null);
		
		add(editorScrollPane);
		add(img);
		add(candidateName);
		repaint();
		validate();
	}
	  private ImageIcon scale(Image src, double scale) 
	  {
	        int type = BufferedImage.TYPE_INT_RGB;
	        BufferedImage dst = new BufferedImage(150, 190, type);
	        Graphics2D g2 = dst.createGraphics();
	        g2.drawImage(src, 0, 0, 150, 190, this);
	        g2.dispose();
	        return new ImageIcon(dst);
	  }
}